home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / comm1 / intsdkss.lha / include / sys / mbuf.h < prev    next >
C/C++ Source or Header  |  1996-04-09  |  4KB  |  116 lines

  1. #ifndef SYS_MBUF_H
  2. #define SYS_MBUF_H
  3.  
  4. /*
  5.  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
  6.  * All rights reserved.
  7.  *
  8.  * Redistribution and use in source and binary forms are permitted
  9.  * provided that the above copyright notice and this paragraph are
  10.  * duplicated in all such forms and that any documentation,
  11.  * advertising materials, and other materials related to such
  12.  * distribution and use acknowledge that the software was developed
  13.  * by the University of California, Berkeley.  The name of the
  14.  * University may not be used to endorse or promote products derived
  15.  * from this software without specific prior written permission.
  16.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  17.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  18.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19.  *
  20.  *    @(#)mbuf.h      7.8.1.3 (Berkeley) 2/14/89
  21.  */
  22.  
  23. /*
  24.  * Constants related to memory allocator.
  25.  */
  26. #define MSIZE        512            /* size of an mbuf */
  27. #define MMINOFF     12            /* mbuf header length */
  28. #define MTAIL        4
  29. #define MMAXOFF     (MSIZE-MTAIL)           /* offset where data ends */
  30. #define MLEN        (MSIZE-MMINOFF-MTAIL)   /* mbuf data length */
  31.  
  32. /*
  33.  * Macros for type conversion
  34.  */
  35.  
  36. /* address in mbuf to mbuf head */
  37. #define dtom(x)         ((struct mbuf *)((long)x & ~(MSIZE-1)))
  38.  
  39. /* mbuf head, to typed data */
  40. #define mtod(x,t)       ((t)((long)(x) + (x)->m_off))
  41.  
  42. struct mbuf {
  43.     struct    mbuf *m_next;        /* next buffer in chain */
  44.     u_long    m_off;            /* offset of data */
  45.     short    m_len;            /* amount of data in this mbuf */
  46.     short    m_type;         /* mbuf type (0 == free) */
  47.     u_char    m_dat[MLEN];        /* data storage */
  48.     struct    mbuf *m_act;        /* link in higher-level mbuf list */
  49. };
  50.  
  51. /* mbuf types */
  52. #define MT_FREE     0    /* should be on free list */
  53. #define MT_DATA     1    /* dynamic (data) allocation */
  54. #define MT_HEADER    2    /* packet header */
  55. #define MT_SOCKET    3    /* socket structure */
  56. #define MT_PCB        4    /* protocol control block */
  57. #define MT_RTABLE    5    /* routing tables */
  58. #define MT_HTABLE    6    /* IMP host tables */
  59. #define MT_ATABLE    7    /* address resolution tables */
  60. #define MT_SONAME    8    /* socket name */
  61. #define MT_ZOMBIE    9    /* zombie proc status */
  62. #define MT_SOOPTS    10    /* socket options */
  63. #define MT_FTABLE    11    /* fragment reassembly header */
  64. #define MT_RIGHTS    12    /* access rights */
  65. #define MT_IFADDR    13    /* interface address */
  66.  
  67. /* flags to m_get */
  68. #define M_DONTWAIT    0
  69. #define M_WAIT        1
  70.  
  71. /* flags to m_pgalloc */
  72. #define MPG_MBUFS    0        /* put new mbufs on free list */
  73. #define MPG_SPACE    2        /* don't free; caller wants space */
  74.  
  75. /* length to m_copy to copy all */
  76. #define M_COPYALL    1000000000
  77.  
  78. /*
  79.  * m_pullup will pull up additional length if convenient;
  80.  * should be enough to hold headers of second-level and higher protocols.
  81.  */
  82. #define MPULL_EXTRA    32
  83.  
  84. /*
  85.  * Original MGET/MFREE were macros that fudged inline proc expansion.  We
  86.  * call m_get/m_free to save quite a lot of space.
  87.  */
  88. #define MGET(m, i, t) (m) = m_get(i, t);
  89. #define MFREE(m, n) (n) = m_free(m);
  90.  
  91. /*
  92.  * Mbuf statistics.
  93.  */
  94. struct mbstat {
  95.     u_long    m_mbufs;    /* mbufs obtained from page pool */
  96.     u_long    m_clusters;    /* clusters obtained from page pool */
  97.     u_long    m_space;    /* interface pages obtained from page pool */
  98.     u_long    m_clfree;    /* free clusters */
  99.     u_long    m_drops;    /* times failed to find space */
  100.     u_long    m_wait;     /* times waited for space */
  101.     u_long    m_drain;    /* times drained protocols for space */
  102.     u_short m_mtypes[32];    /* type specific mbuf allocations */
  103. };
  104.  
  105. #ifdef    KERNEL
  106. #if 0
  107. extern struct mbstat mbstat;
  108. extern struct mbuf *mfree, *mclfree;
  109. extern int m_want;
  110. struct  mbuf *m_get(),*m_getclr(),*m_free(),*m_more(),*m_copy(),*m_pullup();
  111. caddr_t m_clalloc();
  112. #endif
  113. #endif
  114.  
  115. #endif
  116.